<?php

namespace SpecialOperations\GameBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Symfony\Component\DependencyInjection\ContainerAware;
use Doctrine\ORM\Mapping as ORM;

/**
 * SpecialOperations\GameBundle\Entity\Player
 */
class Player extends BaseUser
{
    /**
     * @var string $ip
     */
    private $ip;

    /**
     * @var string $proxy
     */
    private $proxy;

    /**
     * @var datetime $created
     */
    private $created;

    /**
     * @var datetime $updated
     */
    private $updated;

    /**
     * @var bigint $id
     */
    protected $id;

    /**
     * @var SpecialOperations\GameBundle\Entity\Alliance
     */
    private $allianceLead;

    /**
     * @var SpecialOperations\GameBundle\Entity\Alliance
     */
    private $alliance;
    

    /**
     * Set ip
     *
     * @param string $ip
     */
    public function setIp($ip)
    {
        $this->ip = $ip;
    }

    /**
     * Get ip
     *
     * @return string 
     */
    public function getIp()
    {
        return $this->ip;
    }

    /**
     * Set proxy
     *
     * @param string $proxy
     */
    public function setProxy($proxy)
    {
        $this->proxy = $proxy;
    }

    /**
     * Get proxy
     *
     * @return string 
     */
    public function getProxy()
    {
        return $this->proxy;
    }

    /**
     * Set created
     *
     * @param datetime $created
     */
    public function setCreated($created)
    {
        $this->created = $created;
    }

    /**
     * Get created
     *
     * @return datetime 
     */
    public function getCreated()
    {
        return $this->created;
    }

    /**
     * Set updated
     *
     * @param datetime $updated
     */
    public function setUpdated($updated)
    {
        $this->updated = $updated;
    }

    /**
     * Get updated
     *
     * @return datetime 
     */
    public function getUpdated()
    {
        return $this->updated;
    }

    /**
     * Get id
     *
     * @return bigint 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set allianceLead
     *
     * @param SpecialOperations\GameBundle\Entity\Alliance $allianceLead
     */
    public function setAllianceLead(\SpecialOperations\GameBundle\Entity\Alliance $allianceLead)
    {
        $this->allianceLead = $allianceLead;
    }

    /**
     * Get allianceLead
     *
     * @return SpecialOperations\GameBundle\Entity\Alliance 
     */
    public function getAllianceLead()
    {
        return $this->allianceLead;
    }

    /**
     * Set alliance
     *
     * @param SpecialOperations\GameBundle\Entity\Alliance $alliance
     */
    public function setAlliance(\SpecialOperations\GameBundle\Entity\Alliance $alliance)
    {
        $this->alliance = $alliance;
    }

    /**
     * Get alliance
     *
     * @return SpecialOperations\GameBundle\Entity\Alliance 
     */
    public function getAlliance()
    {
        return $this->alliance;
    }
    
    public function preUpdate(){
        if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
            $this->setIp($_SERVER['HTTP_X_FORWARDED_FOR']);
            $this->setProxy($_SERVER['REMOTE_ADDR']);
        }
        else{
            $this->setIp($_SERVER['REMOTE_ADDR']);
        }
    }
    /**
     * @var SpecialOperations\GameBundle\Entity\District
     */
    private $districts;

    public function __construct()
    {
        parent::__construct();
        $this->districts = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Add districts
     *
     * @param SpecialOperations\GameBundle\Entity\District $districts
     */
    public function addDistrict(\SpecialOperations\GameBundle\Entity\District $districts)
    {
        $this->districts[] = $districts;
    }

    /**
     * Get districts
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getDistricts()
    {
        return $this->districts;
    }
    /**
     * @var SpecialOperations\GameBundle\Entity\Brigade
     */
    private $brigades;

    /**
     * @var SpecialOperations\GameBundle\Entity\Officer
     */
    private $officers;

    /**
     * @var SpecialOperations\GameBundle\Entity\Unit
     */
    private $units;

    /**
     * @var SpecialOperations\GameBundle\Entity\UnitGroup
     */
    private $unitGroups;


    /**
     * Add brigades
     *
     * @param SpecialOperations\GameBundle\Entity\Brigade $brigades
     */
    public function addBrigade(\SpecialOperations\GameBundle\Entity\Brigade $brigades)
    {
        $this->brigades[] = $brigades;
    }

    /**
     * Get brigades
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getBrigades()
    {
        return $this->brigades;
    }

    /**
     * Add officers
     *
     * @param SpecialOperations\GameBundle\Entity\Officer $officers
     */
    public function addOfficer(\SpecialOperations\GameBundle\Entity\Officer $officers)
    {
        $this->officers[] = $officers;
    }

    /**
     * Get officers
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getOfficers()
    {
        return $this->officers;
    }

    /**
     * Add units
     *
     * @param SpecialOperations\GameBundle\Entity\Unit $units
     */
    public function addUnit(\SpecialOperations\GameBundle\Entity\Unit $units)
    {
        $this->units[] = $units;
    }

    /**
     * Get units
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getUnits()
    {
        return $this->units;
    }

    /**
     * Add unitGroups
     *
     * @param SpecialOperations\GameBundle\Entity\UnitGroup $unitGroups
     */
    public function addUnitGroup(\SpecialOperations\GameBundle\Entity\UnitGroup $unitGroups)
    {
        $this->unitGroups[] = $unitGroups;
    }

    /**
     * Get unitGroups
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getUnitGroups()
    {
        return $this->unitGroups;
    }
}